#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) 
    {
        int lens = numbers.size();
        vector<int> v;
        int left = 0;
        int right = lens-1;
        while(left <  right)
        {              
            if(numbers[left] +  numbers[right] == target)
            {
                v.push_back(left+1);
                v.push_back(right+1);
                return v;
            }
            else if(numbers[left] +  numbers[right] < target)
            {
                left++;
            }
            else
            {
                right--;
            }
        }
        return v;
    }
};

void printVector(const vector<int>& v)
{
    for(int i = 0; i < v.size();i++)
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

int main()
{
    vector<int> v ={2,7,11,15};
    Solution s;
    printVector(s.twoSum(v,9));
    return 0;
}

